from django.db import models
from user.models import UserList


class ItemList(models.Model):
    price = models.CharField(max_length=200)
    postal = models.CharField(max_length=200)
    title = models.CharField(max_length=200)
    shopNick = models.CharField(max_length=200)
    payNum = models.CharField(max_length=200)
    count = models.PositiveIntegerField()
    image = models.CharField(max_length=200)

    def __str__(self):
        return self.id


# Create your models here.
class Pay_log(models.Model):
    user = models.ForeignKey(UserList, verbose_name='支付用户', on_delete=models.CASCADE)
    item = models.ForeignKey(ItemList, verbose_name='商品', on_delete=models.CASCADE)
    quantity = models.IntegerField(verbose_name='购买数量')
    name = models.CharField(max_length=255, verbose_name='收货人', null=False, blank=False)
    address = models.CharField(max_length=255, verbose_name='收货地址', null=False, blank=False)
    phone = models.CharField(max_length=255, verbose_name='手机号', null=False, blank=False)
    ps = models.CharField(max_length=255, verbose_name='手机号', default=None)
    create_time = models.DateTimeField(auto_created=True, verbose_name='创建时间')


    def __str__(self) -> str:
        return self.user
        
    class Meta:
        verbose_name = '订单记录'